package com.hsd.znsh.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.*;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Set;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-09 10:40:28
 */
@Data
@Entity
@Table(name ="tbl_user")
@JsonIgnoreProperties(ignoreUnknown=true)
public class User implements UserDetails{

    /*主键*/
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /*用户名*/
    private String username;

    /*密码*/
    private String password;

    /*手机号*/
    private String phone;

    /*用户类别*/
    private Integer userType;

    /*创建时间*/
    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDateTime;
    /*修改时间*/
    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateDateTime;

    /*创建者id*/
    private Integer createUserId;

    /*是否删除*/
    @Column(columnDefinition="INT default 0")
    private Integer deleted=0;

    /*海康用户名*/
    private String  hIKUsername;

    /*海康密码*/
    private String  hIKPassword;


    @Transient
    @JsonIgnore
    private Collection<? extends GrantedAuthority> authorities;

    @Override
    @JsonIgnore
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isEnabled() {
        return true;
    }
}
